//
//  TransactionRulesViewController.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/5.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "TransactionRulesViewController.h"
#import "TransactionRulesCell.h"

@interface TransactionRulesViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, weak)UIImageView * backImageView;

@property (nonatomic, strong)UITableView * tableView;

@property (nonatomic, strong)NSArray * showStringArray;


@end

@implementation TransactionRulesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _showStringArray = @[@"品种简称",@"报价单位",@"交易单位",@"合约量",@"最小变动",@"杠杆",@"波动盈亏",@"手续费",@"交易时间"];
    
    [self setupNavBar];
    [self setupUI];
}

- (void)setupNavBar{
    
    self.title = @"交易规则";
    
    UIButton * backButton = [[UIButton alloc] init];
    
    backButton.frame = CGRectMake(15 * SCREENH6, 5 * SCREENH6, 12 * SCREENH6, 20 * SCREENH6);
    [backButton setImage:[UIImage imageNamed:@"1返回"] forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backToAccountView) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem * leftButton = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    
    self.navigationItem.leftBarButtonItem = leftButton;
}



- (void)setupUI{
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    UIImageView * backImage = [[UIImageView alloc] init];
    
    backImage.image = [UIImage imageNamed:@"背景"];
    
    self.backImageView = backImage;
    
    [self.view addSubview:self.backImageView];
    
    self.tableView = [[UITableView alloc] initWithFrame:self.view.frame];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor clearColor];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //    self.tableView.bounces = NO;
    
    [self.tableView registerClass:[TransactionRulesCell class] forCellReuseIdentifier:@"rulesCell"];
    
    [self.view addSubview:self.tableView];
}



- (void)viewDidLayoutSubviews{
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.top.bottom.mas_equalTo(self.view);
    }];
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 9;
    
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    TransactionRulesCell *cell = [tableView dequeueReusableCellWithIdentifier:@"rulesCell" forIndexPath:indexPath];
    
    cell.exhibitionLabel.text = self.showStringArray[indexPath.row];
    
    cell.rulesLabel.text = self.showStringArray[indexPath.row];
    
    if (indexPath.row == 8) {
        cell.lineView.hidden = YES;
    }
//    cell.iconImage.image = [UIImage imageNamed:self.imageNameArray[indexPath.row]];
    
    
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 60 * SCREENH6;
    
}



- (void)backToAccountView{
    
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
